package com.ruoyi.web.controller.pos;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.pos.domain.PosCustomer;
import com.ruoyi.pos.domain.PosDingdanInfo;
import com.ruoyi.pos.service.IPosCustomerService;
import com.ruoyi.pos.service.IPosDingdanInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/pos/pos_dingdan_info")
public class PosDingdanInfoController extends BaseController {

    @Autowired
    private IPosDingdanInfoService posDingdanInfoService;

    @GetMapping("/insertPosDingdanInfo")
    public int insertPosDingdanInfo(PosDingdanInfo posDingdanInfo){
        posDingdanInfo.setCreateTime(new Date());
        return posDingdanInfoService.insertPosDingdanInfo(posDingdanInfo);
    }

    @GetMapping("/updatePosDingdanInfo")
    public int updatePosDingdanInfo(PosDingdanInfo posDingdanInfo){
        posDingdanInfo.setCreateTime(new Date());
        return posDingdanInfoService.updatePosDingdanInfo(posDingdanInfo);
    }

    @GetMapping("/getPosDingdanInfo")
    public PosDingdanInfo getPosDingdanInfo(PosDingdanInfo posDingdanInfo){
       List<PosDingdanInfo> posDingdanInfoList= posDingdanInfoService.selectPosDingdanInfoList(posDingdanInfo);
       if(posDingdanInfoList != null && posDingdanInfoList.size() > 0){
           return posDingdanInfoList.get(0);
       }else {
           return null;
       }
    }
}
